package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@EnableConfigurationProperties(MinioProperties.class)
public class MinioConfiguration {

    @Autowired
    private MinioProperties properties;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder().endpoint(properties.getEndpoint()).credentials(properties.getAccessKey(), properties.getSecretKey()).build();
    }
}

//@Configuration
////@EnableConfigurationProperties(MinioProperties.class)
//@ConfigurationPropertiesScan(basePackages = "com.atguigu.lease.common.minio")
//public class MinioConfiguration {
//
//    @Autowired
//    private MinioProperties properties;
//
//    @Bean
//    public MinioClient minioClient() {
//        // 打印配置值以进行调试
//        System.out.println("Endpoint: " + properties.getEndpoint());
//        System.out.println("Access Key: " + properties.getAccessKey());
//        System.out.println("Secret Key: " + properties.getSecretKey());
//        System.out.println("Bucket Name: " + properties.getBucketName());
//
//        return MinioClient.builder().endpoint(properties.getEndpoint()).credentials(properties.getAccessKey(), properties.getSecretKey()).build();
//    }
//}
